import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';

import 'feedback_manager.dart';

class FeedbackView extends StatelessWidget {
  const FeedbackView({super.key});

  @override
  Widget build(BuildContext context) {
    final manager = Get.put(FeedbackManager());
    final data = Get.parameters;
    return Scaffold(
      appBar: AppBar(
        title: Text(data["title"] ?? "意见反馈"),
        backgroundColor: Colors.white,
        surfaceTintColor: Colors.white,
        centerTitle: true,
        leading: IconButton(
          onPressed: Get.back,
          icon: const Icon(
            Icons.arrow_back_ios_new_rounded,
            color: Colors.black,
          ),
        ),
      ),
      backgroundColor: Colors.white,
      body: ListView(
        padding: const EdgeInsets.symmetric(horizontal: 16),
        children: [
          const SizedBox(height: 24),
          TextField(
            maxLines: 10,
            controller: manager.content,
            decoration: InputDecoration(
              border: InputBorder.none,
              hintText: "请输入你想反馈的意见和问题",
              focusedBorder: OutlineInputBorder(
                borderRadius: BorderRadius.circular(8),
                borderSide: const BorderSide(width: 1, color: Color(0XFFF4DDC2)),
              ),
              enabledBorder: OutlineInputBorder(
                borderRadius: BorderRadius.circular(8),
                borderSide: BorderSide(width: 1, color: Colors.grey.shade300),
              ),
            ),
          ),
          const SizedBox(height: 12),
          TextField(
            keyboardType: TextInputType.number,
            inputFormatters: [
              FilteringTextInputFormatter.digitsOnly,
            ],
            controller: manager.contact,
            decoration: InputDecoration(
              border: InputBorder.none,
              hintText: "请留下您的联系电话,方便后续的联系",
              focusedBorder: OutlineInputBorder(
                borderRadius: BorderRadius.circular(8),
                borderSide: const BorderSide(width: 1, color: Color(0XFFF4DDC2)),
              ),
              enabledBorder: OutlineInputBorder(
                borderRadius: BorderRadius.circular(8),
                borderSide: BorderSide(width: 1, color: Colors.grey.shade300),
              ),
            ),
          ),
          // const SizedBox(height: 12),
          // TextField(
          //   keyboardType: TextInputType.emailAddress,
          //   decoration: InputDecoration(
          //     border: InputBorder.none,
          //     hintText: "（选填）请输入可以联系你的电子邮件地址",
          //     focusedBorder: OutlineInputBorder(
          //       borderRadius: BorderRadius.circular(8),
          //       borderSide: const BorderSide(width: 1, color: Color(0XFFFF6800)),
          //     ),
          //     enabledBorder: OutlineInputBorder(
          //       borderRadius: BorderRadius.circular(8),
          //       borderSide: BorderSide(width: 1, color: Colors.grey.shade300),
          //     ),
          //   ),
          // ),
          const SizedBox(height: 24),
          InkWell(
            onTap: () {
              manager.putFeedback();
            },
            child: Container(
              width: double.maxFinite,
              height: 48,
              alignment: Alignment.center,
              decoration: BoxDecoration(
                gradient: const LinearGradient(colors: [Color(0XFFF4DDC2), Color(0XFFE4B591)]),
                borderRadius: BorderRadius.circular(8),
              ),
              child: const Text(
                "提交反馈",
                style: TextStyle(color: Color(0XFF4A1C02), fontSize: 16, fontWeight: FontWeight.w500),
              ),
            ),
          )
        ],
      ),
    );
  }
}
